#include "Editor.h"
#include "SqlInterface.h"

Editor::Editor(const Event &event, QObject *parent) :
    QObject(parent), m_event(event)
{
    ;
}

bool Editor::insert()
{
    QSqlQuery query;
    query.prepare("INSERT INTO event VALUES(null, "
                  ":format, "
                  ":occur, "
                  ":name, "
                  ":definition, "
                  ":image, "
                  ":icon, "
                  ":color)");
    query.bindValue(":format",     m_event.eventString().format());
    query.bindValue(":occur",      m_event.eventString().occur());
    query.bindValue(":name",       m_event.name());
    query.bindValue(":definition", m_event.definition());
    query.bindValue(":image",      m_event.imagePath());
    query.bindValue(":icon",       m_event.iconPath());
    query.bindValue(":color",      m_event.color());
    query.exec();
    if (query.lastError().isValid()) {
        qDebug() << query.lastError();
        return false;
    }

    return true;
}

bool Editor::modify(int id)
{
    return false;
}

bool Editor::remove(int id)
{
    return false;
}
